package com.yanqu.road.server.logic.recharge;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.config.goods.MallInfo;
import com.yanqu.road.entity.enums.eLogMoneyType;
import com.yanqu.road.entity.recharge.RechargeOrder;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.server.manger.activity.snowgarden.ActivityMallDayBuyMgr;
import com.yanqu.road.utils.property.PropertyHelper;

/**
 * 全服团购
 */
public class ServerBuyRmbMallRecharge extends BaseRecharge {

    public ServerBuyRmbMallRecharge(GamePlayer player, MallInfo mallInfo, ActivityInfo activityInfo) {
        super(player, mallInfo, activityInfo);
    }

    @Override
    protected boolean isRepeatedBuy(String orderNo)  {
        return false;
    }

    @Override
    protected void repeatedBuyLogic() {

    }

    @Override
    protected String addMall(String orderNo, RechargeOrder rechargeOrder) {
        if(null == mallInfo){
            logger.error("ServerBuyRmbMallRecharge add mall fail,mallInfo is null,orderNo:{}", orderNo);
            return "";
        }
        player.getModule(CurrencyModule.class).addCurrency(PropertyHelper.parseStringToProperty(mallInfo.getReward()),
                eLogMoneyType.Recharge, eLogMoneyType.ReChargeGet);
        ActivityMallDayBuyMgr.addMallBuy(mallInfo.getActivityId(), mallInfo.getMallId(), player.getUserId());
//        player.notifyListener( mallInfo.getMallId());
        logger.info("订单: {}, 购买全服礼包 商品: {}", orderNo, mallInfo.getMallId());
        return mallInfo.getReward();
    }
}
